package com.promise.jokerdream.ui.components

import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.promise.jokerdream.R

/**
 * 圆形的自定义 Checkbox 组件
 */
@Composable
fun RoundCheckbox(
    checked: Boolean,
    onCheckedChange: ((Boolean) -> Unit)?,
    modifier: Modifier = Modifier,
    size: Dp = 20.dp,
) {
    Box(
        modifier = modifier
            .size(size)
            .clickable(
                interactionSource = remember { MutableInteractionSource() },
                indication = null
            ) { onCheckedChange?.invoke(!checked) },
        contentAlignment = Alignment.Center
    ) {
        // 使用对应的图标
        Icon(
            painter = painterResource(
                id = if (checked) R.drawable.ic_check else R.drawable.ic_uncheck
            ),
            contentDescription = if (checked) "已选中" else "未选中",
            tint = Color.Unspecified,
            modifier = Modifier.size(size)
        )
    }
}

